<template>
  <div>
    <el-dialog
      v-model="dialogVisible"
      :title="title"
      width="800px"
      @closed="close"
      @open="openfn"
    >
      <zform
        ref="formz"
        colspan="12"
        label-position="left"
        labelwidth="100px"
        :nowdata="formdata"
        :nowinputs="inputs"
      />

      <template #footer>
        <el-button :loading="loading" type="primary" @click="updatafn">
          确定
        </el-button>
        <slot name="btnslot"></slot>
        <el-button @click="close">取消</el-button>
      </template>
    </el-dialog>
  </div>
</template>
<script>
  import zform from '@/components/zFrom/zFrom'

  // bz	输入	备注
  //     wxqk	输入	维修情况
  //     ztwx	输入	维修状态：0-待维修，1-已完成，2-疑难
  //     pic1	输入	图片1路径
  //     pic2	输入	图片2路径
  //     pic3	输入	图片3路径

  export default {
    name: 'afterlistxjpd',
    components: {
      zform,
    },
    emits: ['edtdatafn'],
    data() {
      return {
        dialogVisible: false,
        title: '详情',
        inputs: [
          { label: '创建时间', value: 'sjc', readonly: true },
          { label: '设备序列号', value: 'gtel', readonly: true },
          { label: '维修员', value: 'uUser' },
          { label: '维修情况', value: 'wxqk' },
          {
            label: '维修状态',
            value: 'ztwx',
            type: 'select',
            option: [
              { label: '待维修', value: '0' },
              { label: '已完成', value: '1' },
              { label: '疑难', value: '2' },
            ],
          },
          { label: '备注', value: 'bz' },
          { label: '图片1', value: 'pic1', type: 'imgs' },
          { label: '图片2', value: 'pic2', type: 'imgs' },
          { label: '图片3', value: 'pic3', type: 'imgs' },
        ],
        USearch: [],
        formdata: { uUser: '', gtels: [] },
        loading: false,
        setgtelsfalg: false,
      }
    },
    mounted() {},
    methods: {
      async show(data = {}, asynccallback) {
        let USearchDetailed = await this.$z.$axios.post('/USearchDetailed', {
          sutype: `utype in (22)`,
        })
        this.USearch = USearchDetailed.data
        let USearchoption = this.USearch.map((e) => {
          return { label: e.uUser, value: e.uUser }
        })
        this.inputs = [
          { label: '创建时间', value: 'sjc', readonly: true },
          { label: '设备序列号', value: 'gtel', readonly: true },
          {
            label: '问题类型',
            value: 'type',
            type: 'select',
            option: [
              { label: '故障问题', value: '0' },
              { label: '巡查派单', value: '1' },
            ],
            disabled: true,
          },
          {
            label: '维修员',
            value: 'uUser',
            type: 'select',
            option: USearchoption,
          },
          { label: '维修情况', value: 'wxqk' },
          {
            label: '维修状态',
            value: 'ztwx',
            type: 'select',
            option: [
              { label: '待维修', value: '0' },
              { label: '已完成', value: '1' },
              { label: '疑难', value: '2' },
            ],
          },
          { label: '备注', value: 'bz' },
          { label: '图片1', value: 'pic1', type: 'imgs' },
          { label: '图片2', value: 'pic2', type: 'imgs' },
          { label: '图片3', value: 'pic3', type: 'imgs' },
        ]
        this.asynccallback = asynccallback

        this.formdata = { ...data }
        this.dialogVisible = true
      },

      async getdata() {
        // sutype:
      },
      async updatafn() {
        let formdata = await this.$refs['formz'].validate()
        this.loading = true
        let { data } = await this.$z.$axios
          .post('/AfterListedt', formdata)
          .catch(() => {
            this.loading = false
          })
        let par = this.$z.parfn(data)
        if (par.value == 'succeed') {
          this.$message.success(par.label)
          this.loading = false
          this.getdata()
        } else {
          this.$message.error(par.label)
        }
        this.loading = false
        this.asynccallback()
        this.dialogVisible = false
      },
      close() {
        this.dialogVisible = false
      },
      openfn() {},
    },
  }
</script>
<style lang="scss">
  .useritem {
    height: 40px;
    padding-left: 10px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;

    &:hover {
      background: rgba(255, 255, 255, 0.2);
    }

    &.active {
      background: rgba(255, 255, 255, 0.2);
    }
  }
</style>
